/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.biviz.jgooglegears.jdbc;

import com.biviz.jgooglegears.JGGStubApplet;
import java.applet.Applet;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Administrator
 */
public class JGoogleGearsDriverTest {

    private static Driver driver;

    public JGoogleGearsDriverTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
         System.out.println("setUpClass-----------------------------------");
         driver = DriverManager.getDriver("jdbc:jgooglegears");
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
         System.out.println("tearDownClass-----------------------------------");
    }

    @Before
    public void setUp() throws SQLException {
         System.out.println("setUp-----------------------------------");
//         Connection conn = DriverManager.getConnection("jdbc:jgooglegears");
    }

    @After
    public void tearDown() {
         System.out.println("tearDown-----------------------------------");
    }

     @Test
     public void testAcceptsURL() throws SQLException {
         assertTrue(driver.acceptsURL("jdbc:jgooglegears"));
     }

     @Test
     public void testVersions() throws SQLException {
         driver.getMajorVersion();
         driver.getMinorVersion();
     }

     @Test
     public void testConnect() throws SQLException {
         String[] uuids = JGGStubApplet.getAllAppletUUIDs();

         for(String each : uuids) {
             Properties prop = new Properties();
             prop.setProperty(JGGStubApplet.APPLET_INST_UUID_KEY, each);
             Connection conn = driver.connect("jdbc:jgooglegears:beta.database", prop);
             assertNotNull(conn);
         }
     }

     @Test
     public void failed() {
         System.out.println("failed-----------------------------------");
         fail();
     }
}